<!-- Generated automatically at 12/04/2011 -->
  <div id="advertisements">
  	<?php if(empty($advertisements)) : ?>
  		<div style="color: red; margin: 3px 0px 3px 0px; background-color: #ffffff; border: 1px solid #cccccc; width: 800px; padding: 5px;">Không tìm thấy kết quả nào tương ứng.</div>
  	<?php else : ?>
  		<?php foreach ($advertisements as $advertisement): ?>
  			<?php
  			  list($createdAtDate, $createdAtTime) = explode(' ', $advertisement['createdAt']);
  			  $town = new Town($advertisement['town']);

          //$ad = new Advertisement($advertisement['id']);
          $thumbs = $ad->retrieveThumbs();
          $thumbUrl = $thumbs[0];
  			  
  			  $price = ($advertisement['price'] != 0) ? $advertisement['price'].' €' : '-';
  			  
  			  $category = new Category($advertisement['categoryId']);
  			  
  			  #build the link
  			  $advertisementLink = urlGenUrl($GLOBALS['page'], array('id'=>$advertisement['id']));
  			?>
  			<div class="advertisement">
  				<div class="created-at">
  				  <div class="date"><?php echo stringDateValueToText($createdAtDate) ?></div>
  				  <div class="time"><?php echo stringTimeValueToText($createdAtTime) ?></div>
  				</div>
  				<div class="thumb"><a href='<?php echo $advertisementLink ?>'><img src="<?php echo $thumbUrl ?>" /></a></div>
  				<div class="title"><a href='<?php echo $advertisementLink ?>'><?php echo $advertisement['title'] ?></a></div>
  				<div class="price"><b><?php echo $price ?></b></div>
  				<div class="category"><?php echo $category->getName() ?></div>
  				<div class="town"><?php echo $town->getName()." "."(".$advertisement['town'].")" ?></div>
  			</div>
  		<?php endforeach; ?>
  	<?php endif; ?>
  </div>

	<div class="right-ad">Ad space</div>

<div id="bottom-panel">
</div>
